<%--
 *  File:    DisConfigMain.jsp
 *  @Author: liangchen
 *  Date:    2002/03/20
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<iframe name="reloadHandler" style="display:none"></iframe>



<% //--------------------------------------  setting logger --%>
<%
  Category cat = Category.getInstance("jsp.DisConfigMain");
  //init param
  String strModuleName = "CRM";
  String privilegeCode = "H0252";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/PageDefault.inc"%>

<html>
<head>
<PageFlow:CheckPageFlow pageName="p_disconfigmain"/>
<%--@ include file="/inc/CatchError.inc" --%>
<%
	//params 
	String strIsDefault = null;
	String paraIsDefault = "";
	String isTdNeed = "td-text";
	if("Y".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=Y";
		paraIsDefault = "Y";
		isTdNeed = "need";
	}else if ("N".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=N";
		paraIsDefault = "N";
	}
  String isNew = request.getParameter("isNew");
  if("Y".equals(request.getParameter("isNew"))) {
		isNew = "Y";
	}else if ("N".equals(request.getParameter("isNew"))) {
		isNew = "N";
	}else  {
		isNew = null;
	}
  //params end
  
  HashMap visitprocessinfo = null;
  String valueactivityconfigid = null;
  String dateOpt = null;
  visitprocessinfo = (HashMap)pageContext.getAttribute("visitprocessinfo");
	  if(visitprocessinfo != null&&visitprocessinfo.size()!=0) {
  		if(isNew.equals("Y")){
		  valueactivityconfigid = JspHelper.filterNull( visitprocessinfo.get("tenderconfigid") ).toString();
	  	}
		dateOpt = JspHelper.filterNull( visitprocessinfo.get("createdate") ).toString();
      }else {
	  	  visitprocessinfo = new HashMap();
		  visitprocessinfo.put("status","41");
		  visitprocessinfo.put("createdate",new java.sql.Date(System.currentTimeMillis()));
		  pageContext.setAttribute("visitprocessinfo",visitprocessinfo);
		  valueactivityconfigid = "";
		  visitprocessinfo = (HashMap)pageContext.getAttribute("visitprocessinfo");
      }
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  

	
	
  
%>

<html>
<iframe name="summaryfrm" scrolling="no" frameborder="0"
	style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
<head>
<title>DisConfigMain</title>

<PageFlow:CheckPageFlow pageName="p_disconfigmain" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file ="/inc/NewCalendar.inc" %>
<script language="JavaScript">




function changeStatus()
{
  if(form.status1.value == -1)
  {
	  form.valuename.value = " ";
  }
  else
  {
	 // alert("status1 : " + form.status1.value);
    for (i = 0; i < form.status1.options.length; ++i)
    {
      var opt = form.status1.options[i];
      if (opt.selected)
      {
    	  form.valuename.value = opt.text;
      }
    }
  }
}

function changeProcessType()
{
  if(form.processtype.value == -1)
  {
	  form.groupname.value = " ";
  }
  else
  {
    for (i = 0; i < form.processtype.options.length; ++i)
    {
      var opt = form.processtype.options[i];
      if (opt.selected)
      {
    	  form.groupname.value = opt.text;
      }
    }
  }
}

function page_save()
{	
	
	if(!checkForm(form))   return;
	if(isEmpty(form.tenderconfigname.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Mactivity",false)) %>");
		//label.getLabelName("L_Mactivity")+label.getLabelName("L_IntervalType")+label.getLabelName("L_Name")
		return;
	}
	if(isEmpty(form.status.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Status",false)) %>");
		return;
	}

	//if( "Y" == "<%=paraIsDefault%>") {
		//if(isEmpty(form.processtype.value)) {
		//alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Type",false)) %>");
		//return;
		//}
	//}
	emptyToNull(form);
	var frm = document.form;
	frm.actionname.value = "save";
	frm.target = "_parent";
	frm.submit();
}

function page_back()
{  
  parent.location.href = "DisConfigSummary.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%><%=JspHelper.filterNull( strIsDefault )%>";
}

function page_selectaction()
{
  var activityconfigid = document.form.activityconfigid.value;
  if(activityconfigid==null || activityconfigid==""){
     alert("<%= message.getMessageDesc("SAVE_INFO_FIRST") %>");
     return;
  }
  if(popwindow!=null)
    popwindow.close();
  var activityconfigid = document.form.activityconfigid.value;
  popwindow = window.open('<%=contextPath%>/sfe/activity/Activity4CustomerType.jsp?maxitem=12&languagecode=<%= strLanguageCode%>&<%= OvalTools.randomURL() %>&activityconfigid='+activityconfigid,'newwindow', 'height=400, width=850,top=150,left=300,toolbar=n0, menubar=no, scrollbars=auto, resizable=yes, location=no, status=no');
}
 function deptWindowsContactRelation(){
	  var url = "<%=contextPath%>/sfe/DepartmentWindow.jsp?"+"<%= OvalTools.randomURL() %>";
	  var windowAttribute = "height=400, width=600,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
	  if(popwindow!=null) popwindow.close();
	  popwindow = window.open(url,null,windowAttribute);
 }
  function page_AreaAllWindow(){
	  var url = "<%=contextPath%>/zyl/masterdata/map/SelectAreaTree.jsp?"+"<%= OvalTools.randomURL() %>";
	  var windowAttribute = "height=400, width=600,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
	  if(popwindow!=null) popwindow.close();
	  popwindow = window.open(url,null,windowAttribute);
 }
   function setUsergoup(){
	  var url = "<%=contextPath%>/sfe/UsergroupWindow.jsp?"+"<%= OvalTools.randomURL() %>";
	  var windowAttribute = "height=400, width=600,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
	  if(popwindow!=null) popwindow.close();
	  popwindow = window.open(url,null,windowAttribute);
 }
   function page_selectproductgroup(){
	  var url = "<%=contextPath%>/sfe/ProductgroupWindow.jsp?"+"<%= OvalTools.randomURL() %>";
	  var windowAttribute = "height=400, width=600,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
	  if(popwindow!=null) popwindow.close();
	  popwindow = window.open(url,null,windowAttribute);
 }
 function SetDepts(id,code,name){
   document.form.deptids.value=id;
   //document.form.deptcodes.value=code;
   document.form.deptnames.value=name;  
 }
 function setAreas(areaids,areanames,areacodes){
	document.form.areaids.value = areaids;
	document.form.businessareaname.value = areanames;
	//document.cform.businessareacode.value = areacodes;
} 
 function setUsergoups(id,name){
	document.form.usergroupids.value = id;
	document.form.usergroupnames.value = name;
	//document.cform.businessareacode.value = areacodes;
} 
 function SetProductgroups(id,code,name){
	document.form.productgroupids.value = id;
	document.form.productgroupnames.value = name;
	//document.cform.businessareacode.value = areacodes;
} 
function cleanid(ids,names){
    idObj = eval('document.form.'+ids);
    nameObj = eval('document.form.'+names);
    if (isEmpty(nameObj.value)){
        idObj.value=" ";
    }
}

var popwindow;
function page_selectProvince()
{

  if(popwindow!=null)
    popwindow.close();
  popwindow = window.open('<%=contextPath %>/masterdata/ogm/RegionSelect.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}

function page_setRegion(code,name,id)
{
	
  if(code != document.form.regioncode.value)
  {
	    document.form.citycode.value = "";
	    document.form.cityname.value = "";
	    document.form.cityid.value = "";
		document.form.countycode.value = "";
		document.form.countyname.value = "";
		document.form.countyid.value = "";
  }
  document.form.regioncode.value = code;
  document.form.regionname.value = name;
  document.form.regionid.value = id;
  if (popwindow != null)
    popwindow.close();
}

function page_selectCity(flag,grade)
{
  var regioncode = document.form.regioncode.value;
  var parentcitycode = document.form.citycode.value;
  if(flag=="city")parentcitycode='null';
  if(regioncode=="" || regioncode==-1){
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Province"))%>");
    return;
  }
  if(parentcitycode=="" || parentcitycode==-1){
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_City"))%>");
    return;
  }
  var url='<%=contextPath %>/masterdata/ogm/CitySelect.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN&regioncode=' + regioncode + '&flag=' + flag+'&grade='+grade;
  if(flag=="county"){
   url=url+'&parentcitycode='+parentcitycode;
  }
  if(popwindow!=null)
    popwindow.close();
  popwindow = window.open(url,'newwindow', 'height=250, width=400,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
}

function page_setCity(code,name,id,flag)
{
	if(flag == "county"){
		document.form.countycode.value = code;
		document.form.countyname.value = name;
		document.form.countyid.value = id;
	}else {
		document.form.citycode.value = code;
		document.form.cityname.value = name;
		document.form.cityid.value = id;
		document.form.countycode.value = "";
    	document.form.countyname.value = "";
    	document.form.countyid.value = "";    	
	}
  if (popwindow != null)
    popwindow.close();
}

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
   <form name="form" method="post" action="<%=contextPath %>/Dispatcher">
      <input type="hidden" name="pagename" value="p_disconfigmain">
      <input type="hidden" name="actionname">
      <custom:hidden name="visitprocessinfo"  property="tenderconfigid" value="<%=valueactivityconfigid%>" />


      <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
	  <input type="hidden" name="isNew" value="<%= isNew %>">
	  <%if(isNew.equals("Y")) { %>
	  	<input type="hidden" name="createdate" value="<%= OvalTools.getDate() %>">
	  	<custom:hidden name="userinfo" property="userid" scope="session" changedName="maker" />
	    <custom:hidden name="userinfo" property="userid" scope="session" changedName="contactid" />
      
	  <%}%>
	  	 
      <input type="hidden" name="isdefault" value="<%= paraIsDefault %>">
      <custom:hidden name ="visitprocessinfo" property="activityconfigid" value="<%=valueactivityconfigid%>"/>
      
      <custom:hidden name="userinfo" property="orgname" scope="session" changedName="sellername" />
      <custom:hidden name="visitprocessinfo" property="orgname" scope="session" changedName="sellername" />

	<tr>
            <td colspan="4" class="td_right" height="22"> <a onclick="page_save()"><custom:button type="2" label="L_Save" border="0" tabindex="34" /></a>
            &nbsp;
          </tr>
    <tr>
      <td valign="top">
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
            
           
           <tr>
            <td colspan="4" class="deepblue-left" height="22"> <img src="<%=contextPath %>/images/<%= strLanguageCode %>/quote.gif">
            &nbsp;
          </tr>
          <tr>
          
          <td class="need" width="110" ><%= label.getLabelName("L_IntervalType")+label.getLabelName("L_Name") + label.getLabelName("L_Colon") %></td>
          	<td>
          		<custom:text  name="visitprocessinfo" property="tenderconfigname"  size="20" />
          	
           	</td>
           <td class="need" width="110" ><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
          	<td>
				<!--<custom:select  name="visitprocessinfo" property="status"  optionsName="processstatus" optionValueKey="value" optionInnerTextKey="valuename"/>-->
           	    <custom:selectdic name="visitprocessinfo" property="status"
					dictType="Status" valueCriteria="41,28" command="notnull"
					defaultValue="-------" label="L_StatusName"/></td>
           	</td>
          </tr>
          
          <tr>
          <td class="need" width="110" ><%= label.getLabelName("L_IntervalType")+label.getLabelName("L_GroupNumber") + label.getLabelName("L_Colon") %></td>
          <td>
				<custom:text  name="visitprocessinfo" property="tenderconfigcode"  size="20" />
           	</td>
           	<td class="td-text" width="110" ><%= label.getLabelName("L_CreateDate") + label.getLabelName("L_Colon") %></td>
           	<td>
				<custom:write name="visitprocessinfo" property="createdate" dataType="date" dataFormatName="dateformat"/>
           	</td>
          </tr>
           <tr>
           	<td class="td-text"><%= label.getLabelName("L_Province") + label.getLabelName("L_Colon") %></td>
			<td>
				   <custom:text property="regioncode" name="visitprocessinfo"  size="10" readonly="true"/>
	              <a onclick="javascript:page_selectProvince();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
	              <custom:text property="regionname" name="visitprocessinfo" readonly="true" size="20"/>
	              <custom:hidden property="regionid" name="visitprocessinfo" />
			</td>
          	<td class="td-text"><%= label.getLabelName("L_City") + label.getLabelName("L_Colon") %></td>
          	<td>
            	<custom:text property="citycode" name="visitprocessinfo"  size="10" readonly="true"/>
            	<a onclick="javascript:page_selectCity('city',1);"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
            	<custom:text property="cityname" name="visitprocessinfo" readonly="true" size="20"/>
            	<custom:hidden property="cityid" name="visitprocessinfo" />
            </td>		
          </tr>          
          <tr>
            <td class="td-text"><%= label.getLabelName("L_YLCounty") + label.getLabelName("L_Colon") %></td>
            <td colspan="3">
              	<custom:text property="countycode"  name="visitprocessinfo" size="10" readonly="true" />
              	<a onclick="javascript:page_selectCity('county',2);"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
              	<custom:text property="countyname" name="visitprocessinfo" readonly="true" size="20"/>
              	<custom:hidden property="countyid" name="visitprocessinfo"/>
            </td>
            
            
            
            
          <tr>
            <td class="td-text"width="110" ><%= label.getLabelName("L_Comments") + label.getLabelName("L_Colon") %></td>
             <td colspan="3">
				<custom:text  name="visitprocessinfo" property="comments" size="60" />
           	</td>
           
          </tr>            

		</tr>

        </table>
      </td>
    </tr>
    <tr>
      <td class="summary_top"></td>
    </tr>
    <tr>
    <td height="49" class="td_center">
      <a onclick="javascript:page_back()"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>
    </td>
    </tr>
</form>
</table>
<script language="JavaScript" src="../js/Calendar.js" ></script>
<%@include file="/inc/AlertError.inc"%>
</body>
</html>


           		